package com.juneng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.Condition;
import com.juneng.utils.BeanCopyUtils;
import com.juneng.entity.Follow;
import com.juneng.mapper.FollowMapper;
import com.juneng.service.IFollowService;
import com.juneng.dto.FollowDto;
import com.juneng.dto.FollowQueryDto;
import com.juneng.vo.FollowVo;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
import java.util.List;
/**
 * 关注信息 服务实现类
 *
 * @author zds
 * @since 2021-07-14
 */
@Service
@AllArgsConstructor
public class FollowServiceImpl implements IFollowService {

    protected FollowMapper followMapper;
    @Override
    public IPage<FollowVo> page(FollowQueryDto dto) {
        IPage<FollowVo> page = Condition.getPage(dto);
        return followMapper.page(page,dto);
    }

    @Override
    public List<Follow> list(FollowQueryDto dto) {
        QueryWrapper<Follow> queryWrapper = new QueryWrapper<>(BeanCopyUtils.copy(dto,Follow.class));
        return followMapper.selectList(queryWrapper);
    }

    @Override
    public Integer save(FollowDto dto) {
        return followMapper.insert(BeanCopyUtils.copy(dto,Follow.class));
    }

    @Override
    public Integer updateById(FollowDto dto) {
        return followMapper.updateById(BeanCopyUtils.copy(dto,Follow.class));
    }

    @Override
    public Integer deleteLogic(List<Integer> toIntList) {
        return followMapper.deleteBatchIds(toIntList);
    }

    @Override
    public Follow getById(Integer id) {
        return followMapper.selectById(id);
    }
}
